home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / BYACC__ / NULLABLE.C < prev    next >
C/C++ Source or Header  |  1989-11-19  |  787b  |  55 lines

  1. #include <stdio.h>
  2. #include "defs.h"
  3. #include "gram.h"
  4. #include "new.h"
  5.  
  6.  
  7. set_nullable()
  8. {
  9.   register int i, icon;
  10.   register int done, flag;
  11.  
  12.   nullable = NEW2(nsyms, char);
  13.  
  14.   done = 0;
  15.   while ( ! done)
  16.     {
  17.       done = 1;
  18.       for (i = 0; i < nitems; i++)
  19.     {
  20.       flag = 1;
  21.       icon = ritem[i];
  22.       while (icon > 0)
  23.         {
  24.           if ( ! nullable[icon]) flag = 0;
  25.           i++;
  26.           icon = ritem[i];
  27.         }
  28.       if (flag)
  29.         {
  30.           icon = rlhs[-icon];
  31.           if ( ! nullable[icon])
  32.         {
  33.           nullable[icon] = 1;
  34.           done = 0;
  35.         }
  36.         }
  37.     }
  38.     }
  39.  
  40. #ifdef DEBUG
  41.   for (i = 0; i < nsyms; i++)
  42.     {
  43.       if (nullable[i])
  44.         printf("%s is nullable\n", symbol_name[i]);
  45.       else
  46.     printf("%s is not nullable\n", symbol_name[i]);
  47.     }
  48. #endif
  49. }
  50.  
  51. free_nullable()
  52. {
  53.   FREE(nullable);
  54. }
  55.